﻿#region Using namespaces

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

#endregion

namespace BOL.Apps.GeneNetworkBrowser
{
    public class NCR : INamed
    {
        public struct Survival
        {
            #region Private variables

            private double[] _times;
            private bool[] _endPoints;

            #endregion

            #region Public properties

            public double[] Times { get { return _times; } set { _times = value; } }
            
            public bool[] EndPoints { get { return _endPoints; } set { _endPoints = value; } }

            #endregion

            #region Constructors

            public Survival(double[] times, bool[] endPoints)
            {
                this._times = times;
                this._endPoints = endPoints;
            }

            public Survival(double[] times)
                : this(times, new bool[times.Length]) { }

            #endregion
        }

        public struct Expression
        {
            #region Private variables

            private string[] _probesetIds;
            private double[][] _values;

            #endregion

            #region Public properties

            public string[] ProbesetIds { get { return _probesetIds; } set { _probesetIds = value; } }
            
            public double[][] Values { get { return _values; } set { _values = value; } }

            public int NumberOfProbesets { get { return _probesetIds.Length; } }

            #endregion

            #region Constructor

            public Expression(string[] probesetIds, double[][] values)
            {
                this._probesetIds = probesetIds;
                this._values = values;
            }

            #endregion
        }

        public struct Covariate
        {
            #region Private variables

            private string _label;
            private string[] _values;

            #endregion

            #region Public properties

            public string Label { get { return _label; } set { _label = value; } }

            public string[] Values { get { return _values; } set { _values = value; } }

            #endregion

            #region Constructor

            public Covariate(string label, string[] values)
            {
                this._label = label;
                this._values = values;
            }

            #endregion
        }

        #region Private variables

        private string _name;

        private string[] _ids;

        private int _length;

        private Survival _survival;

        private Expression _expression;

        private ObservableCollection<Covariate> _covariates;

        #endregion

        #region Public properties

        public string Name { get { return _name; } set { _name = value; } }

        public string[] Ids { get { return _ids; } set { _ids = value; } }

        public int Length { get { return _length; } }

        public Survival SurvivalData { get { return _survival; } set { _survival = value; } }

        public Expression ExpressionData { get { return _expression; } set { _expression = value; } }

        public ObservableCollection<Covariate> CovariatesData { get { return _covariates; } set { _covariates = value; } }

        #endregion

        #region Constructor

        public NCR(string name, string[] ids, double[] times, bool[] endPoints, string[] probesetIds, double[][] values, ObservableCollection<Covariate> covariates)
        {
            this._name = name;
            this._ids = ids;
            this._length = ids.Length;

            if (_length != times.Length)
                throw new ArgumentException();
            if (_length != endPoints.Length)
                throw new ArgumentException();
            this._survival = new Survival(times, endPoints);

            if (_length != values[0].Length)
                throw new ArgumentException();
            this._expression = new Expression(probesetIds, values);
            this._covariates = covariates;
        }

        #endregion

        #region Public methods

        #endregion
    }
}
